The Notification module in the Scripting app allows you to schedule, manage, and display local notifications with advanced trigger types, interactive actions, and rich UI capabilities.
Use Notification.schedule to schedule a local notification. It supports content, triggers, tap behaviors, action buttons, rich UI, and delivery configurations:
| Name | Type | Description |
|---|---|---|
title |
string |
Required. Notification title. |
subtitle |
string? |
Optional. Additional context. |
body |
string? |
Optional. Main content text. |
badge |
number? |
Optional. App icon badge count. |
silent |
boolean? |
Optional. Defaults to false. If true, delivers silently without sound. |
interruptionLevel |
"active" | "passive" | "timeSensitive" |
Optional. Defines priority and delivery behavior. |
userInfo |
Record<string, any>? |
Optional. Custom metadata. |
threadIdentifier |
string? |
Optional. Identifier for grouping notifications. |
trigger |
TimeIntervalNotificationTrigger | CalendarNotificationTrigger | LocationNotificationTrigger | null |
Optional. Defines when the notification is delivered. |
actions |
NotificationAction[]? |
Optional. Action buttons shown when long-pressing or expanding the notification. |
customUI |
boolean? |
Optional. Enables rich notification UI using notification.tsx. |
tapAction |
"none" | { type: "runScript", scriptName: string } | { type: "openURL", url: string } |
Optional. Controls what happens when the user taps the notification. |
avoidRunningCurrentScriptWhenTapped |
boolean? |
Deprecated. Use tapAction: "none" instead. |
Deprecated:
triggerTimeandrepeatsTypeare deprecated. Usetriggerinstead.
tapAction)The tapAction parameter gives you precise control over what happens when the user taps the notification:
"none" – Do nothing when tapped{ type: "runScript", scriptName: string } – Run a different script{ type: "openURL", url: string } – Open a deep link or web pageIf tapAction is not provided, the default behavior is to run the current script, and the notification details can be accessed using Notification.current.
Triggers a notification after a specified number of seconds.
timeInterval: Delay in secondsrepeats: Whether it repeatsnextTriggerDate(): Returns the next expected trigger dateTriggers when the current date matches specific calendar components.
year, month, day, hour, etc.Triggers when entering or exiting a geographic region.
Use the actions array to define buttons shown when the notification is expanded:
Script.createRunURLScheme(...) to generate Scripting app URLsYou can provide an interactive JSX interface:
customUI: true in the Notification.schedule() callnotification.tsx fileNotification.present(element) inside that fileNotification.present(element: JSX.Element): voidMust be called from notification.tsx. Renders the element as the expanded notification interface.
notification.tsx| Method | Description |
|---|---|
getAllDelivereds() |
Returns all delivered notifications. |
getAllPendings() |
Returns all scheduled but undelivered notifications. |
removeAllDelivereds() |
Removes all delivered notifications. |
removeAllPendings() |
Cancels all pending notifications. |
removeDelivereds(ids) |
Removes delivered notifications with matching IDs. |
removePendings(ids) |
Cancels scheduled notifications with matching IDs. |
getAllDeliveredsOfCurrentScript() |
Delivered notifications from the current script only. |
getAllPendingsOfCurrentScript() |
Scheduled notifications from the current script only. |
removeAllDeliveredsOfCurrentScript() |
Clears current script’s delivered notifications. |
removeAllPendingsOfCurrentScript() |
Cancels current script’s pending notifications. |
setBadgeCount(count) |
Sets the app icon badge value. |
Use Notification.current to get launch context when the script is opened from a notification tap:
NotificationRequest Fields| Field | Description |
|---|---|
identifier |
Unique ID for the request |
content.title |
Notification title |
content.subtitle |
Optional subtitle |
content.body |
Notification body |
content.userInfo |
Custom metadata |
content.threadIdentifier |
Grouping key |
trigger |
Trigger object that controls delivery |
This example demonstrates a full-featured notification with actions, rich UI, and repeated delivery.
notification.tsxThe Notification API in the Scripting app supports:
tapActionnotification.tsxFor future compatibility, always prefer the trigger and tapAction parameters over deprecated ones like triggerTime and avoidRunningCurrentScriptWhenTapped.